package stringExertises;

import java.util.Scanner;

/**
 * @author: bamboo_shoot
 * @date: 20/2/3 18:15
 * @description: 键盘录入一个字符串，统计字符串中大小写字母及数字字符个数.
 */
public class TheNumberStatistical {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一段字符作为统计");
        String line = sc.nextLine();
        int capital = 0;
        int lowercase = 0;
        int number = 0;
        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            if ('Z' >= c && c >= 'A') {
                capital++;
            } else if (c >= 'a' && c <= 'z') {
                lowercase++;
            } else if (c >= '0' && c <= '9') {
                number++;
            } else {
                System.out.println("无效的字符"+c);
            }
        }
        System.out.println("capital"+capital);
        System.out.println("lowercase"+lowercase);
        System.out.println("number"+number);
    }
}
